package com.ku.log.dao.factory;

import com.ku.log.dao.LogMapper;
import com.ku.log.dao.MysqlLogMapper;
import com.ku.log.dao.OracleLogMapper;
import com.ku.log.support.constant.JdbcDriverType;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: GZQ
 * @create: 2020/08/09
 * @description: 根据jdbcDriver来选择对应的LogMapper
 **/
@Component
public class LogMapperFactory {
    @Autowired
    private MysqlLogMapper mysqlLogMapper;
    @Autowired
    private OracleLogMapper oracleLogMapper;

    public LogMapper getLogMapper(String jdbcDriver) {
        switch (jdbcDriver) {
            case JdbcDriverType.MYSQL:
            case JdbcDriverType.MYSQL2:
                return mysqlLogMapper;
            case JdbcDriverType.ORACLE:
                return oracleLogMapper;
            default:
                return null;
        }
    }
}
